<template>
  <section>
    <el-table :data="listInstance" v-if="listInstance" size="small"
              ref="multipleTable" @selection-change="selEvent">
      <el-table-column type="selection" width="50px"/>
      <el-table-column type="index"/>
      <el-table-column label="时间" prop="created" :formatter="dateFormatter"/>
      <el-table-column label="标题" prop="title" />
    </el-table>
    <el-button size="mini" type="success" @click="subItemBtn">提交</el-button>
  </section>
</template>

<script>
  import dataFormater from '@/common/date-formater'
  import errHandler from '@/assets/errHandler.js'
  import {mapGetters, mapActions, mapMutations} from 'vuex'
  export default {
    name: "choiceInstance",
    data(){
      return{
        listInstance:null,
        totalPage:0,
        multipleSelection:[]
      }
    },
    created(){
      //
      this.getInstance()
    },
    methods:{
      ...mapActions({
        fetch: 'fetch'
      }),
      dateFormatter(a,b,c,d){
        return dataFormater.formatDatetime(c)
      },
      addBtn(){
        this.showQa=true
      },
      getInstance(){
        this.fetch({name:"listInstance",data:{page:0}})
          .then(res=>{
            console.log('实例列表------',res)
            this.listInstance=res.content
            this.totalPage=res.totalPages
          })
          .catch(err=>{
            console.log(err)
            errHandler.handle(this,err)
          })
      },
      subItemBtn(){
        console.log('看下所选的',this.multipleSelection)
        this.$emit('submitItem',this.multipleSelection)
      },
      selEvent(e){
        this.multipleSelection=e
      }
    }

  }
</script>

<style scoped>

</style>
